/**
 * 
 */
package com.cms.show.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cms.pojo.Article;
import com.cms.pojo.Category;
import com.cms.pojo.Channel;
import com.cms.pojo.vo.ArticleVo;

/**
 * @author zhaoyan
 *
 * 2020年1月9日
 */
public interface ArticleMapper {
	
	/**
	 * 
	 * @param articleVo	模糊查询的条件
	 * @return
	 */
	public List<Article> findArticle(ArticleVo articleVo);

	/**
	 * @param articleId 文章的id
	 * @return
	 */
	public Article getArticle(@Param("id") Integer articleId);

	/**
	 * @param id
	 * @param hot
	 * @return
	 */
	@Update("UPDATE cms_article SET `status` = #{status} WHERE id = #{id}")
	public Integer checkArticle(@Param("id")Integer id, @Param("status")Integer status);

	/**
	 * @param id
	 * @param hot
	 * @return
	 */
	@Update("UPDATE cms_article SET `hot` = #{hot} WHERE id = #{id}")
	public Integer setHot(@Param("id")Integer id, @Param("hot") Integer hot);

	/**
	 * @return
	 */
	@Select("SELECT * FROM cms_channel ORDER BY id ASC")
	public List<Channel> findChannel();

	/**
	 * @param channelID
	 * @return
	 */
	@Select("SELECT * FROM cms_category WHERE channel_id = #{value} ORDER BY id ASC")
	public List<Category> findCategory(Integer channelID);

	/**
	 * @param article
	 * @return
	 */
	public int addarticle(Article article);

	/**
	 * @param id
	 * @return
	 */
	@Select("SELECT id,title,content,picture,channel_id,category_id,user_id,hits,hot,`status`,deleted,created,updated,commentCnt,articleType"
			+ " FROM cms_article WHERE user_id = #{value} AND deleted = 0")
	public List<Article> findArticleByUid(Integer id);

	/**
	 * @param id
	 * @return
	 */
	@Update("UPDATE cms_article SET deleted = 1 WHERE id = #{value}")
	public Integer delArticleById(Integer id);
	
	
}
